<template>
    <div>
        <el-form ref="student">
        <!-- 修改 -->

        <div style="width:800px">
            <el-form-item label="修改大类">
                <el-input v-model="class_name">类名</el-input>
            </el-form-item>
            <el-form-item label="修改大类id">
                <el-input v-model="class_id">大类id</el-input>
            </el-form-item>

            <el-form-item style="width:970px">
                <el-button type="primary" @click="updateClass(class_name, class_id)">修改</el-button>
            </el-form-item>
        </div>

        <div style="width:800px">
            <el-form-item label="修改小类名">
                <el-input v-model="category_name"></el-input>
            </el-form-item>

            <el-form-item label="修改小类的id">
                <el-input v-model="category_id"></el-input>
            </el-form-item>

            <el-form-item label="修改小类所属的大类的id">
                <el-input v-model="class_id"></el-input>
            </el-form-item>

            <el-form-item style="width:970px">
                <el-button type="primary" @click="updateLittleClass(category_name, category_id, class_id)">修改</el-button>
            </el-form-item>
        </div>
        </el-form>
    </div>
</template>
<script>
export default {
    data() {
        return {
            class_name: '',
            category_name: '',
            class_id: '',
            category_id: ''
        };
    },
    methods: {
        updateClass: function(class_name, class_id) {
            console.log(class_id);
            console.log('ccccccccccciiiiiiiii');
            var that = this;

            console.log('DDDDDDDDDDDDDDDDDDDDDDDDDDD');
            this.axios({
                method: 'post',
                url: 'http://localhost:8080/s/updateGoodsClass',
                //修改了提交的数据类型为json格式
                headers: { 'Content-Type': 'application/json;charset=utf-8' },
                data: JSON.stringify({
                    class_name, 
                    class_id
                })
            })
                .then(res => {
                    console.log(res.data);
                })
                .catch(error => {
                    console.log(error);
                });
        },
        updateLittleClass: function(category_name, category_id, class_id) {
            console.log('aaaaaaaaaaaa');
            var that = this;

            console.log('ddddddddddddddddddd');
            this.axios({
                method: 'post',
                url: 'http://localhost:8080/s/updateGoodsCategory',
                //修改了提交的数据类型为json格式
                headers: { 'Content-Type': 'application/json;charset=utf-8' },
                data: JSON.stringify({
                    category_name, 
                    category_id,
                    class_id
                })
            })
                .then(res => {
                    console.log(res.data);
                })
                .catch(error => {
                    console.log(error);
                });
        }
    }
};
</script>
<style scoped></style>
